package com.bdqn.ch05.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bdqn.ch05.entity.User;
import com.bdqn.ch05.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceBiz implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public List<User> selectListBiz() {
        return userMapper.selectList(null);
    }

    public User selectByUnameBiz(String uname) {
        Wrapper<User> queryWrapper = new QueryWrapper<>();
        ((QueryWrapper<User>) queryWrapper).eq("usr_name", uname);
        return userMapper.selectOne(queryWrapper);
    }
}
